import { Toast } from "vant";
import cTitle from "components/title";
export default {
  components: {
    cTitle
  },
  data() {
    return {
      active: 0,
      refundId: null,
      refundDetail: {},
      steps: []
    };
  },
  activated() {
    this.refundId = Number(this.$route.query.refundId);
    this.refundDetails();
  },
  methods: {
    refundDetails() {
      let json = {
        refund_id: this.refundId
      };
      $http.get("refund.detail", json, "正在获取").then(
        response => {
          if (response.result == 1) {
            let refundDetail = response.data;
            let steps = [];
            let active = 0;
            if (refundDetail.create_time) {
              steps.push({
                text: "申请退款",
                desc: refundDetail.create_time
              });
              steps.push({
                text: "退款成功",
                desc: ""
              });
            }
            if (refundDetail.refund_time) {
              steps[1].desc = refundDetail.refund_time;
              active = 1;
            }
            if (refundDetail.reject_time) {
              steps[1].text = "申请驳回";
              steps[1].desc = refundDetail.reject_time;
              active = 1;
            }
            this.refundDetail = refundDetail;
            this.steps = steps;
            this.active = active;
          } else {
            this.$dialog.alert({ message: response.msg });
          }
        },
        function(response) {
          // console.log(response);
          // error callback
        }
      );
    },
    copyCode() {
      Toast("复制成功");
    },
    onError() {
      Toast("复制成功");
    }
  }
};
